let classObj = {
  students: [],
  total: 5,
  getTo: function (name) {
    this.students.push(name);
    console.log(`${name}到了班级`);
    if (this.students.length === this.total) {
      console.log("班里人到齐了");
    }
  },
  leave: function (name) {
    const isExist = this.students.indexOf(name);
    if (~isExist) {
      console.log(`${name}离开了班级`);
      this.students.splice(isExist, 1);
    } else {
      console.log(`${name}今天没有来班里`);
    }
  },
  classOver() {
    this.students = [];
    console.log("班级解散了");
  },
};

classObj.getTo("小王");
classObj.getTo("小一");
classObj.getTo("小二");
classObj.getTo("小三");
classObj.getTo("小四");
classObj.getTo("小五");
classObj.getTo("小六");
classObj.leave("小六");
classObj.leave("小七");
classObj.classOver();
